Skip to content

fix: log every line of multi-line messages - #8

Open
aslilac wants to merge 2 commits into
mainfrom
lilac/log-multiline-messages
Open

fix: log every line of multi-line messages#8
aslilac wants to merge 2 commits into
mainfrom
lilac/log-multiline-messages

Conversation

@aslilac

@aslilac aslilac commented Aug 13, 2026

Copy link
Copy Markdown
Member

The daemon log truncates any message at its first newline and appends ....
Process error output is routinely multi-line, and the cause of a failure
usually appears after the first symptom of it, so the useful half of the
message was being discarded.

Each line of a message is now written as its own log line carrying the full
timestamp, level, and scope prefix. Neutralizing control characters per line
also makes the separate carriage-return truncation unnecessary.

Found while investigating a customer file sync failure, where the logged
error named a symptom and hid the cause:

[I] [sync.sync_IxTbhpj3] Beta connection failure: ... unable to copy agent
binary: unable to run SCP process: /bin/sh: -c: line 1: syntax error near
unexpected token `%a'...
Before and after, from the test in this PR

Given scp stderr reproduced locally against a real sshd:

/bin/sh: 1: Syntax error: Bad for loop variable
/bin/sh: 1: exec: /c/Program Files/Coder/bin/coder.exe: not found
scp: Connection closed

Before, the cause and the outcome are both gone:

2026-08-12 23:08:21 [I] [sync.sync_IxTbhpj3] unable to run SCP process: /bin/sh: 1: Syntax error: Bad for loop variable...

After:

2026-08-12 23:08:21 [I] [sync.sync_IxTbhpj3] unable to run SCP process: /bin/sh: 1: Syntax error: Bad for loop variable
2026-08-12 23:08:21 [I] [sync.sync_IxTbhpj3] /bin/sh: 1: exec: /c/Program Files/Coder/bin/coder.exe: not found
2026-08-12 23:08:21 [I] [sync.sync_IxTbhpj3] scp: Connection closed

The test commit is separate from the fix commit, so the failure is visible in
history.

Notes for the reviewer:

  • Lines are written in a single Write call so a multi-line record stays
    contiguous when several goroutines log at once.
  • pkg/agent has two pre-existing test failures on a clean main; they need
    a built agent bundle and are unrelated.
  • The Commit Verification job will fail. These commits are not
    cryptographically signed, and re-signing them means rewriting history,
    which I am not permitted to do. Existing commits on this fork are also
    missing their sign-off. Happy for someone to re-sign before merge.

This PR was created by Coder Agents on behalf of @aslilac.

Signed-off-by: aslilac <aslilac@users.noreply.github.com>
Signed-off-by: McKayla はな <kayla@tree.camp>
Signed-off-by: McKayla はな <kayla@tree.camp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant